
/* *  
 * ---------------------------------------- *  
 * 鍩庡競閫夋嫨缁勪欢 v1.0  
 * Author: VVG  
 * QQ: 83816819  
 * Mail: mysheller@163.com  
 * http://www.cnblogs.com/NNUF/  
 * ---------------------------------------- *  
 * Date: 2012-07-10  
 * ---------------------------------------- *  
 * */ 
 
/* *  
 * 鍏ㄥ眬绌洪棿 Vcity  
 * */ 
var Vcity = {};  
/* *  
 * 闈欐�鏂规硶闆� 
 * @name _m  
 * */ 
Vcity._m = {  
    /* 閫夋嫨鍏冪礌 */ 
    $:function (arg, context) {  
        var tagAll, n, eles = [], i, sub = arg.substring(1);  
        context = context || document;  
        if (typeof arg == 'string') {  
            switch (arg.charAt(0)) {  
                case '#':  
                    return document.getElementById(sub);  
                    break;  
                case '.':  
                    if (context.getElementsByClassName) return context.getElementsByClassName(sub);  
                    tagAll = Vcity._m.$('*', context);  
                    n = tagAll.length;  
                    for (i = 0; i < n; i++) {  
                        if (tagAll[i].className.indexOf(sub) > -1) eles.push(tagAll[i]);  
                    }  
                    return eles;  
                    break;  
                default:  
                    return context.getElementsByTagName(arg);  
                    break;  
            }  
        }  
    },  
 
    /* 缁戝畾浜嬩欢 */ 
    on:function (node, type, handler) {  
        node.addEventListener ? node.addEventListener(type, handler, false) : node.attachEvent('on' + type, handler);  
    },  
 
    /* 鑾峰彇浜嬩欢 */ 
    getEvent:function(event){  
        return event || window.event;  
    },  
 
    /* 鑾峰彇浜嬩欢鐩爣 */ 
    getTarget:function(event){  
        return event.target || event.srcElement;  
    },  
 
    /* 鑾峰彇鍏冪礌浣嶇疆 */ 
    getPos:function (node) {  
        var scrollx = document.documentElement.scrollLeft || document.body.scrollLeft,  
            scrollt = document.documentElement.scrollTop || document.body.scrollTop;  
        var pos = node.getBoundingClientRect();  
        return {top:pos.top + scrollt, right:pos.right + scrollx, bottom:pos.bottom + scrollt, left:pos.left + scrollx }  
    },  
 
    /* 娣诲姞鏍峰紡鍚�*/ 
    addClass:function (c, node) {  
        if(!node)return;  
        node.className = Vcity._m.hasClass(c,node) ? node.className : node.className + ' ' + c ;  
    },  
 
    /* 绉婚櫎鏍峰紡鍚�*/ 
    removeClass:function (c, node) {  
        var reg = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");  
        if(!Vcity._m.hasClass(c,node))return;  
        node.className = reg.test(node.className) ? node.className.replace(reg, '') : node.className;  
    },  
 
    /* 鏄惁鍚湁CLASS */ 
    hasClass:function (c, node) {  
        if(!node || !node.className)return false;  
        return node.className.indexOf(c)>-1;  
    },  
 
    /* 闃绘鍐掓场 */ 
    stopPropagation:function (event) {  
        event = event || window.event;  
        event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;  
    },  
    /* 鍘婚櫎涓ょ绌烘牸 */ 
    trim:function (str) {  
        return str.replace(/^\s+|\s+$/g,'');  
    }  
};  
 
/* 鎵�湁鍩庡競鏁版嵁,鍙互鎸夌収鏍煎紡鑷娣诲姞锛堝寳浜瑋beijing|bj锛夛紝鍓�6鏉′负鐑棬鍩庡競 */ 
 
Vcity.allCity = ['鍖椾含|beijing|bj','涓婃捣|shanghai|sh', '閲嶅簡|chongqing|cq',  '娣卞湷|shenzhen|sz', '骞垮窞|guangzhou|gz', '鏉窞|hangzhou|hz',  
    '鍗椾含|nanjing|nj', '鑻忓窞|shuzhou|sz', '澶╂触|tianjin|tj', '鎴愰兘|chengdu|cd', '鍗楁槍|nanchang|nc', '涓変簹|sanya|sy','闈掑矝|qingdao|qd',  
    '鍘﹂棬|xiamen|xm', '瑗垮畨|xian|xa','闀挎矙|changsha|cs','鍚堣偉|hefei|hf','瑗胯棌|xizang|xz', '鍐呰挋鍙neimenggu|nmg', '瀹夊簡|anqing|aq', '闃挎嘲鍕抾ataile|atl', '瀹夊悍|ankang|ak',  
    '闃垮厠鑻弢akesu|aks', '鍖呭ご|baotou|bt', '鍖楁捣|beihai|bh', '鐧捐壊|baise|bs','淇濆北|baoshan|bs', '闀挎不|changzhi|cz', '闀挎槬|changchun|cc', '甯稿窞|changzhou|cz', '鏄岄兘|changdu|cd',  
    '鏈濋槼|chaoyang|cy', '甯稿痉|changde|cd', '闀跨櫧灞眧changbaishan|cbs', '璧ゅ嘲|chifeng|cf', '澶у悓|datong|dt', '澶ц繛|dalian|dl', '杈惧幙|daxian|dx', '涓滆惀|dongying|dy', '澶у簡|daqing|dq', '涓逛笢|dandong|dd',  
    '澶х悊|dali|dl', '鏁︾厡|dunhuang|dh', '閯傚皵澶氭柉|eerduosi|eeds', '鎭╂柦|enshi|es', '绂忓窞|fuzhou|fz', '闃滈槼|fuyang|fy', '璐甸槼|guiyang|gy',  
    '妗傛灄|guilin|gl', '骞垮厓|guangyuan|gy', '鏍煎皵鏈▅geermu|gem', '鍛煎拰娴╃壒|huhehaote|hhht', '鍝堝瘑|hami|hm',  
    '榛戞渤|heihe|hh', '娴锋媺灏攟hailaer|hle', '鍝堝皵婊▅haerbin|heb', '娴峰彛|haikou|hk', '榛勫北|huangshan|hs', '閭兏|handan|hd',  
    '姹変腑|hanzhong|hz', '鍜岀敯|hetian|ht', '鏅嬫睙|jinjiang|jj', '閿﹀窞|jinzhou|jz', '鏅痉闀噟jingdezhen|jdz',  
    '鍢夊唱鍏硘jiayuguan|jyg', '浜曞唸灞眧jinggangshan|jgs', '娴庡畞|jining|jn', '涔濇睙|jiujiang|jj', '浣虫湪鏂瘄jiamusi|jms', '娴庡崡|jinan|jn',  
    '鍠�粈|kashi|ks', '鏄嗘槑|kunming|km', '搴峰畾|kangding|kd', '鍏嬫媺鐜涗緷|kelamayi|klmy', '搴撳皵鍕抾kuerle|kel', '搴撹溅|kuche|kc', '鍏板窞|lanzhou|lz',  
    '娲涢槼|luoyang|ly', '涓芥睙|lijiang|lj', '鏋楄姖|linzhi|lz', '鏌冲窞|liuzhou|lz', '娉稿窞|luzhou|lz', '杩炰簯娓瘄lianyungang|lyg', '榛庡钩|liping|lp',  
    '杩炴垚|liancheng|lc', '鎷夎惃|lasa|ls', '涓存钵|lincang|lc', '涓存矀|linyi|ly', '鑺掑競|mangshi|ms', '鐗′腹姹焲mudanjiang|mdj', '婊℃床閲寍manzhouli|mzl', '缁甸槼|mianyang|my',  
    '姊呭幙|meixian|mx', '婕犳渤|mohe|mh', '鍗楀厖|nanchong|nc', '鍗楀畞|nanning|nn', '鍗楅槼|nanyang|ny', '鍗楅�|nantong|nt', '閭ｆ媺鎻恷nalati|nlt',  
    '瀹佹尝|ningbo|nb', '鏀�灊鑺眧panzhihua|pzh', '琛㈠窞|quzhou|qz', '绉︾殗宀泑qinhuangdao|qhd', '搴嗛槼|qingyang|qy', '榻愰綈鍝堝皵|qiqihaer|qqhe',  
    '鐭冲搴剕shijiazhuang|sjz',  '娌堥槼|shenyang|sy', '鎬濊寘|simao|sm', '閾滀粊|tongren|tr', '濉斿煄|tacheng|tc', '鑵惧啿|tengchong|tc', '鍙板窞|taizhou|tz',  
    '閫氳窘|tongliao|tl', '澶師|taiyuan|ty', '濞佹捣|weihai|wh', '姊у窞|wuzhou|wz', '鏂囧北|wenshan|ws', '鏃犻敗|wuxi|wx', '娼嶅潑|weifang|wf', '姝﹀し灞眧wuyishan|wys', '涔屽叞娴╃壒|wulanhaote|wlht',  
    '娓╁窞|wenzhou|wz', '涔岄瞾鏈ㄩ綈|wulumuqi|wlmq', '涓囧窞|wanzhou|wz', '涔屾捣|wuhai|wh', '鍏翠箟|xingyi|xy', '瑗挎槍|xichang|xc',  '瑗勬▕|xiangfan|xf',  
    '瑗垮畞|xining|xn', '閿℃灄娴╃壒|xilinhaote|xlht', '瑗垮弻鐗堢撼|xishuangbanna|xsbn', '寰愬窞|xuzhou|xz', '涔変箤|yiwu|yw', '姘稿窞|yongzhou|yz', '姒嗘灄|yulin|yl', '寤跺畨|yanan|ya', '杩愬煄|yuncheng|yc',  
    '鐑熷彴|yantai|yt', '閾跺窛|yinchuan|yc', '瀹滄槍|yichang|yc', '瀹滃|yibin|yb', '鐩愬煄|yancheng|yc', '寤跺悏|yanji|yj', '鐜夋爲|yushu|ys', '浼婂畞|yining|yn', '鐝犳捣|zhuhai|zh', '鏄�|zhaotong|zt',  
    '寮犲鐣寍zhangjiajie|zjj', '鑸熷北|zhoushan|zs', '閮戝窞|zhengzhou|zz', '涓崼|zhongwei|zw', '鑺锋睙|zhijiang|zj', '婀涙睙|zhanjiang|zj'];  
 
/* 姝ｅ垯琛ㄨ揪寮�绛涢�涓枃鍩庡競鍚嶃�鎷奸煶銆侀瀛楁瘝 */ 
 
Vcity.regEx = /^([\u4E00-\u9FA5\uf900-\ufa2d]+)\|(\w+)\|(\w)\w*$/i;  
Vcity.regExChiese = /([\u4E00-\u9FA5\uf900-\ufa2d]+)/;  
 
/* *  
 * 鏍煎紡鍖栧煄甯傛暟缁勪负瀵硅薄oCity锛屾寜鐓-h,i-p,q-z,hot鐑棬鍩庡競鍒嗙粍锛� 
 * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{i:[1.2.3],j:[1,2,3]},QRSTUVWXYZ:{}}  
 * */ 
 
(function () {  
    var citys = Vcity.allCity, match, letter,  
        regEx = Vcity.regEx,  
        reg2 = /^[a-h]$/i, reg3 = /^[i-p]$/i, reg4 = /^[q-z]$/i;  
    if (!Vcity.oCity) {  
        Vcity.oCity = {hot:{},ABCDEFGH:{}, IJKLMNOP:{}, QRSTUVWXYZ:{}};  
        //console.log(citys.length);  
        for (var i = 0, n = citys.length; i < n; i++) {  
            match = regEx.exec(citys[i]);  
            letter = match[3].toUpperCase();  
            if (reg2.test(letter)) {  
                if (!Vcity.oCity.ABCDEFGH[letter]) Vcity.oCity.ABCDEFGH[letter] = [];  
                Vcity.oCity.ABCDEFGH[letter].push(match[1]);  
            } else if (reg3.test(letter)) {  
                if (!Vcity.oCity.IJKLMNOP[letter]) Vcity.oCity.IJKLMNOP[letter] = [];  
                Vcity.oCity.IJKLMNOP[letter].push(match[1]);  
            } else if (reg4.test(letter)) {  
                if (!Vcity.oCity.QRSTUVWXYZ[letter]) Vcity.oCity.QRSTUVWXYZ[letter] = [];  
                Vcity.oCity.QRSTUVWXYZ[letter].push(match[1]);  
            }  
            /* 鐑棬鍩庡競 鍓�6鏉�*/ 
            if(i<16){  
                if(!Vcity.oCity.hot['hot']) Vcity.oCity.hot['hot'] = [];  
                Vcity.oCity.hot['hot'].push(match[1]);  
            }  
        }  
    }  
})();  
/* 鍩庡競HTML妯℃澘 */ 
Vcity._template = [  
    '<p class="tip">鐑棬鍩庡競(鏀寔姹夊瓧/鎷奸煶)</p>',  
    '<ul>',  
    '<li class="on">鐑棬鍩庡競</li>',  
    '<li>ABCDEFGH</li>',  
    '<li>IJKLMNOP</li>',  
    '<li>QRSTUVWXYZ</li>',  
    '</ul>' 
];  
 
/* *  
 * 鍩庡競鎺т欢鏋勯�鍑芥暟  
 * @CitySelector  
 * */ 
 
Vcity.CitySelector = function () {  
    this.initialize.apply(this, arguments);  
};  
 
Vcity.CitySelector.prototype = {  
 
    constructor:Vcity.CitySelector,  
 
    /* 鍒濆鍖�*/ 
 
    initialize :function (options) {  
        var input = options.input;  
        this.input = Vcity._m.$('#'+ input);  
        this.inputEvent();  
    },  
 
    /* *  
     * @createWarp  
     * 鍒涘缓鍩庡競BOX HTML 妗嗘灦  
     * */ 
 
    createWarp:function(){  
        var inputPos = Vcity._m.getPos(this.input);  
        var div = this.rootDiv = document.createElement('div');  
        var that = this;  
 
        // 璁剧疆DIV闃绘鍐掓场  
        Vcity._m.on(this.rootDiv,'click',function(event){  
            Vcity._m.stopPropagation(event);  
        });  
 
        // 璁剧疆鐐瑰嚮鏂囨。闅愯棌寮瑰嚭鐨勫煄甯傞�鎷╂  
        Vcity._m.on(document, 'click', function (event) {  
            event = Vcity._m.getEvent(event);  
            var target = Vcity._m.getTarget(event);  
            if(target == that.input) return false;  
            //console.log(target.className);  
            if (that.cityBox)Vcity._m.addClass('hide', that.cityBox);  
            if (that.ul)Vcity._m.addClass('hide', that.ul);  
            if(that.myIframe)Vcity._m.addClass('hide',that.myIframe);  
        });  
        div.className = 'citySelector';  
        div.style.position = 'absolute';  
        div.style.left = inputPos.left + 'px';  
        div.style.top = inputPos.bottom + 'px';  
        div.style.zIndex = 999999;  
 
        // 鍒ゆ柇鏄惁IE6锛屽鏋滄槸IE6闇�娣诲姞iframe鎵嶈兘閬綇SELECT妗� 
        var isIe = (document.all) ? true : false;  
        var isIE6 = this.isIE6 = isIe && !window.XMLHttpRequest;  
        if(isIE6){  
            var myIframe = this.myIframe =  document.createElement('iframe');  
            myIframe.frameborder = '0';  
            myIframe.src = 'about:blank';  
            myIframe.style.position = 'absolute';  
            myIframe.style.zIndex = '-1';  
            this.rootDiv.appendChild(this.myIframe);  
        }  
 
        var childdiv = this.cityBox = document.createElement('div');  
        childdiv.className = 'cityBox';  
        childdiv.id = 'cityBox';  
        childdiv.innerHTML = Vcity._template.join('');  
        var hotCity = this.hotCity =  document.createElement('div');  
        hotCity.className = 'hotCity';  
        childdiv.appendChild(hotCity);  
        div.appendChild(childdiv);  
        this.createHotCity();  
    },  
 
    /* *  
     * @createHotCity  
     * TAB涓嬮潰DIV锛歨ot,a-h,i-p,q-z 鍒嗙被HTML鐢熸垚锛孌OM鎿嶄綔  
     * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{},QRSTUVWXYZ:{}}  
     **/ 
 
    createHotCity:function(){  
        var odiv,odl,odt,odd,odda=[],str,key,ckey,sortKey,regEx = Vcity.regEx,  
            oCity = Vcity.oCity;  
        for(key in oCity){  
            odiv = this[key] = document.createElement('div');  
            // 鍏堣缃叏閮ㄩ殣钘廻ide  
            odiv.className = key + ' ' + 'cityTab hide';  
            sortKey=[];  
            for(ckey in oCity[key]){  
                sortKey.push(ckey);  
                // ckey鎸夌収ABCDEDG椤哄簭鎺掑簭  
                sortKey.sort();  
            }  
            for(var j=0,k = sortKey.length;j<k;j++){  
                odl = document.createElement('dl');  
                odt = document.createElement('dt');  
                odd = document.createElement('dd');  
                odt.innerHTML = sortKey[j] == 'hot'?'&nbsp;':sortKey[j];  
                odda = [];  
                for(var i=0,n=oCity[key][sortKey[j]].length;i<n;i++){  
                    str = '<a href="javascript:">' + oCity[key][sortKey[j]][i] + '</a>';  
                    odda.push(str);  
                }  
                odd.innerHTML = odda.join('');  
                odl.appendChild(odt);  
                odl.appendChild(odd);  
                odiv.appendChild(odl);  
            }  
 
            // 绉婚櫎鐑棬鍩庡競鐨勯殣钘廋SS  
            Vcity._m.removeClass('hide',this.hot);  
            this.hotCity.appendChild(odiv);  
        }  
        document.body.appendChild(this.rootDiv);  
        /* IE6 */ 
        this.changeIframe();  
 
        this.tabChange();  
        this.linkEvent();  
    },  
 
    /* *  
     *  tab鎸夊瓧姣嶉『搴忓垏鎹� 
     *  @ tabChange  
     * */ 
 
    tabChange:function(){  
        var lis = Vcity._m.$('li',this.cityBox);  
        var divs = Vcity._m.$('div',this.hotCity);  
        var that = this;  
        for(var i=0,n=lis.length;i<n;i++){  
            lis[i].index = i;  
            lis[i].onclick = function(){  
                for(var j=0;j<n;j++){  
                    Vcity._m.removeClass('on',lis[j]);  
                    Vcity._m.addClass('hide',divs[j]);  
                }  
                Vcity._m.addClass('on',this);  
                Vcity._m.removeClass('hide',divs[this.index]);  
                /* IE6 鏀瑰彉TAB鐨勬椂鍊�鏀瑰彉Iframe 澶у皬*/ 
                that.changeIframe();  
            };  
        }  
    },  
 
    /* *  
     * 鍩庡競LINK浜嬩欢  
     *  @linkEvent  
     * */ 
 
    linkEvent:function(){  
        var links = Vcity._m.$('a',this.hotCity);  
        var that = this;  
        for(var i=0,n=links.length;i<n;i++){  
            links[i].onclick = function(){  
                that.input.value = this.innerHTML;  
                Vcity._m.addClass('hide',that.cityBox);  
                /* 鐐瑰嚮鍩庡競鍚嶇殑鏃跺�闅愯棌myIframe */ 
                Vcity._m.addClass('hide',that.myIframe);  
            }  
        }  
    },  
 
    /* *  
     * INPUT鍩庡競杈撳叆妗嗕簨浠� 
     * @inputEvent  
     * */ 
 
    inputEvent:function(){  
        var that = this;  
        Vcity._m.on(this.input,'click',function(event){  
            event = event || window.event;  
            if(!that.cityBox){  
                that.createWarp();  
            }else if(!!that.cityBox && Vcity._m.hasClass('hide',that.cityBox)){  
                // slideul 涓嶅瓨鍦ㄦ垨鑰�slideul瀛樺湪浣嗘槸鏄殣钘忕殑鏃跺� 涓よ�涓嶈兘鍏卞瓨  
                if(!that.ul || (that.ul && Vcity._m.hasClass('hide',that.ul))){  
                    Vcity._m.removeClass('hide',that.cityBox);  
 
                    /* IE6 绉婚櫎iframe 鐨刪ide 鏍峰紡 */ 
                    //alert('click');  
                    Vcity._m.removeClass('hide',that.myIframe);  
                    that.changeIframe();  
                }  
            }  
        });  
        Vcity._m.on(this.input,'focus',function(){  
            that.input.select();  
            if(that.input.value == '鍩庡競鍚�') that.input.value = '';  
        });  
        Vcity._m.on(this.input,'blur',function(){  
            if(that.input.value == '') that.input.value = '鍩庡競鍚�';  
        });  
        Vcity._m.on(this.input,'keyup',function(event){  
            event = event || window.event;  
            var keycode = event.keyCode;  
            Vcity._m.addClass('hide',that.cityBox);  
            that.createUl();  
 
            /* 绉婚櫎iframe 鐨刪ide 鏍峰紡 */ 
            Vcity._m.removeClass('hide',that.myIframe);  
 
            // 涓嬫媺鑿滃崟鏄剧ず鐨勬椂鍊欐崟鎹夋寜閿簨浠� 
            if(that.ul && !Vcity._m.hasClass('hide',that.ul) && !that.isEmpty){  
                that.KeyboardEvent(event,keycode);  
            }  
        });  
    },  
 
    /* *  
     * 鐢熸垚涓嬫媺閫夋嫨鍒楄〃  
     * @ createUl  
     * */ 
 
    createUl:function () {  
        //console.log('createUL');  
        var str;  
        var value = Vcity._m.trim(this.input.value);  
        // 褰搗alue涓嶇瓑浜庣┖鐨勬椂鍊欐墽琛� 
        if (value !== '') {  
            var reg = new RegExp("^" + value + "|\\|" + value, 'gi');  
            var searchResult = [];  
            for (var i = 0, n = Vcity.allCity.length; i < n; i++) {  
                if (reg.test(Vcity.allCity[i])) {  
                    var match = Vcity.regEx.exec(Vcity.allCity[i]);  
                    if (searchResult.length !== 0) {  
                        str = '<li><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';  
                    } else {  
                        str = '<li class="on"><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';  
                    }  
                    searchResult.push(str);  
                }  
            }  
            this.isEmpty = false;  
            // 濡傛灉鎼滅储鏁版嵁涓虹┖  
            if (searchResult.length == 0) {  
                this.isEmpty = true;  
                str = '<li class="empty">瀵逛笉璧凤紝娌℃湁鎵惧埌鏁版嵁 "<em>' + value + '</em>"</li>';  
                searchResult.push(str);  
            }  
            // 濡傛灉slideul涓嶅瓨鍦ㄥ垯娣诲姞ul  
            if (!this.ul) {  
                var ul = this.ul = document.createElement('ul');  
                ul.className = 'cityslide';  
                this.rootDiv && this.rootDiv.appendChild(ul);  
                // 璁板綍鎸夐敭娆℃暟锛屾柟鍚戦敭  
                this.count = 0;  
            } else if (this.ul && Vcity._m.hasClass('hide', this.ul)) {  
                this.count = 0;  
                Vcity._m.removeClass('hide', this.ul);  
            }  
            this.ul.innerHTML = searchResult.join('');  
 
            /* IE6 */ 
            this.changeIframe();  
 
            // 缁戝畾Li浜嬩欢  
            this.liEvent();  
        }else{  
            Vcity._m.addClass('hide',this.ul);  
            Vcity._m.removeClass('hide',this.cityBox);  
 
            Vcity._m.removeClass('hide',this.myIframe);  
 
            this.changeIframe();  
        }  
    },  
 
    /* IE6鐨勬敼鍙橀伄缃㏒ELECT 鐨�IFRAME灏哄澶у皬 */ 
    changeIframe:function(){  
        if(!this.isIE6)return;  
        this.myIframe.style.width = this.rootDiv.offsetWidth + 'px';  
        this.myIframe.style.height = this.rootDiv.offsetHeight + 'px';  
    },  
 
    /* *  
     * 鐗瑰畾閿洏浜嬩欢锛屼笂銆佷笅銆丒nter閿� 
     * @ KeyboardEvent  
     * */ 
 
    KeyboardEvent:function(event,keycode){  
        var lis = Vcity._m.$('li',this.ul);  
        var len = lis.length;  
        switch(keycode){  
            case 40: //鍚戜笅绠ご鈫� 
                this.count++;  
                if(this.count > len-1) this.count = 0;  
                for(var i=0;i<len;i++){  
                    Vcity._m.removeClass('on',lis[i]);  
                }  
                Vcity._m.addClass('on',lis[this.count]);  
                break;  
            case 38: //鍚戜笂绠ご鈫� 
                this.count--;  
                if(this.count<0) this.count = len-1;  
                for(i=0;i<len;i++){  
                    Vcity._m.removeClass('on',lis[i]);  
                }  
                Vcity._m.addClass('on',lis[this.count]);  
                break;  
            case 13: // enter閿� 
                this.input.value = Vcity.regExChiese.exec(lis[this.count].innerHTML)[0];  
                Vcity._m.addClass('hide',this.ul);  
                Vcity._m.addClass('hide',this.ul);  
                /* IE6 */ 
                Vcity._m.addClass('hide',this.myIframe);  
                break;  
            default:  
                break;  
        }  
    },  
 
    /* *  
     * 涓嬫媺鍒楄〃鐨刲i浜嬩欢  
     * @ liEvent  
     * */ 
 
    liEvent:function(){  
        var that = this;  
        var lis = Vcity._m.$('li',this.ul);  
        for(var i = 0,n = lis.length;i < n;i++){  
            Vcity._m.on(lis[i],'click',function(event){  
                event = Vcity._m.getEvent(event);  
                var target = Vcity._m.getTarget(event);  
                that.input.value = Vcity.regExChiese.exec(target.innerHTML)[0];  
                Vcity._m.addClass('hide',that.ul);  
                /* IE6 涓嬫媺鑿滃崟鐐瑰嚮浜嬩欢 */ 
                Vcity._m.addClass('hide',that.myIframe);  
            });  
            Vcity._m.on(lis[i],'mouseover',function(event){  
                event = Vcity._m.getEvent(event);  
                var target = Vcity._m.getTarget(event);  
                Vcity._m.addClass('on',target);  
            });  
            Vcity._m.on(lis[i],'mouseout',function(event){  
                event = Vcity._m.getEvent(event);  
                var target = Vcity._m.getTarget(event);  
                Vcity._m.removeClass('on',target);  
            })  
        }  
    }  
}; // JavaScript Document